package edu.scau.pro.hotel.service.impl;

import edu.scau.pro.hotel.entity.HotelCustomer;
import edu.scau.pro.hotel.mapper.HotelCustomerMapper;
import edu.scau.pro.hotel.service.IHotelCustomerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelCustomer)表服务实现类
 *
 * @author CJW
 * @since 2022-03-21 20:16:25
 */
@Service("hotelCustomerService")
public class HotelCustomerServiceImpl implements IHotelCustomerService {
    @Resource
    private HotelCustomerMapper hotelCustomerMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param customerId 主键
     * @return 实例对象
     */
    @Override
    public HotelCustomer queryById(Integer customerId) {
        return this.hotelCustomerMapper.queryById(customerId);
    }

    /**
     * 查询指定行
     *
     * @param hotelCustomer 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelCustomer> queryAll(HotelCustomer hotelCustomer) {
        return this.hotelCustomerMapper.queryAll(hotelCustomer);
    }

    /**
     * 新增数据
     *
     * @param hotelCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public HotelCustomer insert(HotelCustomer hotelCustomer) {
        this.hotelCustomerMapper.insert(hotelCustomer);
        return hotelCustomer;
    }

    /**
     * 修改数据
     *
     * @param hotelCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public HotelCustomer update(HotelCustomer hotelCustomer) {
        this.hotelCustomerMapper.update(hotelCustomer);
        return this.queryById(hotelCustomer.getCustomerId());
    }

    /**
     * 通过主键删除数据
     *
     * @param customerId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer customerId) {
        return this.hotelCustomerMapper.deleteById(customerId) > 0;
    }
}
